//bench.js
const app = getApp()
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js')

Page({
  data: {
    patrolInfo: {
      pileCode: 'Z0000',
      hospitalName: '苏州九龙',
      location: '门诊',
      description: '123',
      imgArray: ['/images/jietu.png', '/images/jietu.png']
    },
    
  },
  onLoad: function (options) {
    let that = this
    console.log("options",options)
    that.setData({
      pileCode: options.pileCode,
      hospitalName: options.hospitalName,
      hospitalId: options.hospitalId,
      scrollHeight:app.getScrollHeight(45)
    })
    wx.request({
      url: util.CONST_DATA.BASE_URL + 'pile/maintainInfo',//这里请求接口21,获取桩位的维修信息
      header: app.globalData.header,
      data: { hid: parseInt(that.data.pileCode.replace(/[^0-9]/ig,"")) },
      method: "POST",
      success(res) {
        console.log("接口21success>>", res)
        if(res.data.result==0){
          that.setData({
            equipInfo: res.data.data
          })
        }
      },
      fail(res) {
        console.log("接口21fail>>", res)
      }
    })
  },
  onReady: function () {
    // Do something when page ready.
  },
  onShow: function () {
    // Do something when page show.
  },
  onHide: function () {
    // Do something when page hide.
  },
  onUnload: function () {
    // Do something when page close.
  },
  maintainFinish: function(){
    let that = this
    lbbService.updatePileStat({
        equId: parseInt(that.data.pileCode.replace(/[^0-9]/ig,"")),
        nowStat: 1,//正常
        lbmid: parseInt(that.data.hospitalId)
      },function(res){
        wx.showToast({
          title: '已完成维修',
        })
        setTimeout(function () {
          wx.navigateBack({
            delta: 1
          })
        }, 1500)
      })
  },
  

})